package org.dtrd.modules.evaluation.entity.bean;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.dtrd.modules.evaluation.constant.Evaluation;
import org.dtrd.modules.evaluation.entity.po.DtrdEntEvaluationRdMmas8;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * @Author: QR
 * @Date: 2021/9/27-10:41
 */
@ApiModel("MMAS8量表数据")
@Data
public class Mmas8Info {

    private Integer dataId;

    @ApiModelProperty("患者id")
    private Integer patientId;

    @ApiModelProperty("创建时间")
    private Date createTime;

    @ApiModelProperty("答案")
    private List<Integer> answers;

    @ApiModelProperty("总分")
    private Float score;

    @ApiModelProperty("输出结果")
    private String output;

    public Mmas8Info parseFromPo(DtrdEntEvaluationRdMmas8 po){
        this.setDataId(po.getDataId());
        this.setPatientId(po.getPatientId());
        this.setCreateTime(po.getCreateTime());
        this.setScore(po.getScore());
        this.setOutput(po.getOutput());
        String[] answerStrings = po.getInput().split(",");
        ArrayList<Integer> answers = new ArrayList<>(Evaluation.ProblemNum.MMAS8.getNum());
        for (String s : answerStrings) {
            Integer answer = Integer.parseInt(s);
            answers.add(answer);
        }
        this.setAnswers(answers);
        return this;
    }
}
